//#include <bits/stdc++.h>
#include <stdc++.h>
using namespace std;
int main()
{
    int n;
    char c;
    double h;
    cin >> n;
    while (n--)
    {
        cin >> c >> h;
        if (c == 'M')
        {
            printf("%.2lf\n", h / 1.09);
        }
        else
        {
            printf("%.2lf\n", h * 1.09);
        }
    }

    return 0;
}
